<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>vue-css</title>
    <script src="https://unpkg.com/vue@3/dist/vue.global.js"></script>
    <style>
        .transition{
            transition: background 3s ease 0s;
        }
    </style>
</head>
<body>
    <div id="root"></div>

<script>
    const app=Vue.createApp({
        data(){
            return{
                transition:{
                    backgroundColor:'red',

                    color:"pink"
                }
            }
        },
        methods:{
            handleClick(){
       
                if(this.transition.backgroundColor==='red'){
             
                    this.transition.backgroundColor='yellow'
                }else{
                    this.transition.backgroundColor='red'
                }
       
            }
        },
        template:`<div class="transition" :style="transition">a</div>
        <button  @click='handleClick'>切换</button>
        `
    })
    app.mount('#root')
</script>
</body>
</html>